<!DOCTYPE html>
<html ng-app="Manage">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title></title>
</head>
<link rel="stylesheet" type="text/css" href="/Public/css/index.css"/>
<link rel="stylesheet" type="text/css" href="/Public/css/nav.css"/>
<link rel="stylesheet" type="text/css" href="/Public/css/base.css"/>
<link rel="stylesheet" type="text/css" href="/Public/css/FileAction-index.css"/>

<link rel="stylesheet" type="text/css" href="/Public/css/FileAction-quickManage.css"/>
<link rel="stylesheet" type="text/css" href="/Public/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="/Public/Font-Awesome-3.2.1/css/font-awesome.min.css"/>
<style type="text/css">
	
</style>
<body ng-controller="TaskCtrl">
 <include file="Public/nav" /> 
<div class="container" style="width: 1050px;margin:47px auto">
		<div class="row" >
				<include file="Public/panel" /> 
				<div class="col-md-9">	
					<!-- ↓↓↓↓↓↓↓↓↓↓↓↓↓↓个性化代码区↓↓↓↓↓↓↓↓↓↓↓↓↓-->
					<include file="Public/fileaction-select" /> 
					<div class="filelist">
						<ul>
							 <li ng-repeat="i in list">
								<input type="checkbox" ng-model="i.checked" ng-change="selectOne()"  > 
								<a href="" class="filename">{{i.filename}} </a>
								<span class="uploadtime">{{i.datetime}}</span><!-- 标记：克隆  -->
								<a href="" ng-click="del(i)">删除</a>|<!-- <a href="">修改标记</a> -->
							</li>
						</ul>	
						
						 <label for="flag">全选
						     <input id="flag" type="checkbox" ng-model="select_all" ng-change="selectAll()">
						 </label>

						<br/><br/>
						<button class="btn btn-danger btn-xs" ng-click="delMore()">删除选中</button>		
					</div>
					<!-- ↑↑↑↑↑↑↑↑↑↑↑↑↑↑个性化代码区↑↑↑↑↑↑↑↑↑↑↑↑↑-->
				</div>				
		</div>
</div>

<include file="Public/footer" /> 
</body>
<script src="/Public/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/Public/bootstrap/js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
<script src="/Public/js/angular.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/Public/layer/layer.js" type="text/javascript" charset="utf-8"></script>

 <script type="text/javascript">

 		var app = angular.module('Manage',[]); //声明module
		app.controller('TaskCtrl',function($scope,$http){ //声明控制器

			$scope.list = {$list};
		    $scope.checked = [];

		    $scope.selectAll = function () {
		        if($scope.select_all) {
		            $scope.checked = [];
		            angular.forEach($scope.list, function (i) {
		                i.checked = true;
		                $scope.checked.push(i.id);
		            })
		        }else {
		            angular.forEach($scope.list, function (i) {
		                i.checked = false;
		                $scope.checked = [];
		            })
		        }
		        console.log($scope.checked);
		    };
		     

		     $scope.selectOne = function () {
		        angular.forEach($scope.list , function (i) {
		            var index = $scope.checked.indexOf(i.id);
		            if(i.checked && index === -1) {
		                $scope.checked.push(i.id);
		            } else if (!i.checked && index !== -1){
		                $scope.checked.splice(index, 1);
		            };
		        })

		        if ($scope.list.length === $scope.checked.length) {
		            $scope.select_all = true;
		        } else {
		            $scope.select_all = false;
		        }
		        console.log($scope.checked);
		    }

			$scope.del = function(i){

				$http.post('{:U('del')}', i.id)
		        .success(function(data) {
		        	if(data.code == 0){
		        		layer.msg(data.msg,function(){
		        			location.reload();
		        		});
		        	}else{
		        		layer.msg(data.msg);
		        	}
		           
		        });

			},

			$scope.delMore = function(){

				$http.post('{:U('delMore')}', $scope.checked)
		        .success(function(data) {
		        	if(data.code == 0){
		        		layer.msg(data.msg,function(){
		        			location.reload();
		        		});
		        	}else{
		        		layer.msg(data.msg);
		        	}
		           
		        });
			}

		});


 </script>
</html>